cmake_minimum_required(VERSION 3.16)

project(ijkplayer-linux)

set(ijkplayer_demo ijkplayer_linux)
set(alsa_demo alsa_wav)

# 设置 C++ 标准
#set(CMAKE_CXX_STANDARD 14)
set(C_STANDARD 99)

add_definitions(-D__LINUX__)
set(PLATFORM x64)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
   message(STATUS "x86_64 architecture detected")
   set(CMAKE_BUILD_TYPE Debug)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
   message(STATUS "ARM architecture detected")
   set(PLATFORM arm)
else()
   message(WARNING "Unknown architecture")
endif()

# 包目录
include_directories(
   ${PROJECT_SOURCE_DIR}/../ijkmedia
   "${PROJECT_SOURCE_DIR}/../ijkmedia/${PLATFORM}/install/include"
   "/home/ido/source/ffmpeg-3.4.2/${PLATFORM}/install/include"
)
link_directories(
   "${PROJECT_SOURCE_DIR}/../ijkmedia/${PLATFORM}/install/lib"
   "/home/ido/source/ffmpeg-3.4.2/${PLATFORM}/install/lib"
)

# ijkplayer demo
add_executable(${ijkplayer_demo} ijkplayer_linux.c)

set_target_properties(${ijkplayer_demo} PROPERTIES LINK_FLAGS "-Wl,--disable-new-dtags,-rpath,/home/ido/source/ffmpeg-3.4.2/x64/install/lib")
target_link_libraries(${ijkplayer_demo} PRIVATE ijkplayer yuv avcodec avformat swscale swresample avutil asound pthread m)

# alsa demo
add_executable(${alsa_demo} alsa_wav.c)
target_link_libraries(${alsa_demo} PRIVATE asound)

# 设置输出路径
set(LIBRARY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/${PLATFORM}/bin")

# 安装动态库和头文件
install(TARGETS ${ijkplayer_demo} LIBRARY DESTINATION bin)
install(TARGETS ${alsa_demo} LIBRARY DESTINATION bin)

